Repository navigation
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideImplementationConnect deletion handling when a foreign toplevel handle is created and delete handles that close before they are added to the monitor.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="panels/dock/taskmanager/desktopfileparserfactory.h" line_range="61" />
<code_context>
desktopFileParser = QSharedPointer<T>(new T(id));
m_desktopFileParsers.insert(id, desktopFileParser.toWeakRef());
}
+ pruneStaleEntries();
return desktopFileParser;
}
</code_context>
<issue_to_address>
**Parser lookups scan entire cache**
When many parser IDs are live and callers repeatedly query or create parsers, `createById()` calls `pruneStaleEntries()` on every call, and `pruneStaleEntries()` scans the entire `QMap`, making repeated lookups linear in the cache size and adding avoidable dock latency.
Avoid scanning the full cache on cache hits, and prune stale entries only when needed.
</issue_to_address>
### Comment 2
<location path="tests/panels/dock/docktests/desktopfileparserfactorytests.cpp" line_range="1" />
<code_context>
+// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
+//
+// SPDX-License-Identifier: GPL-3.0-or-later
</code_context>
<issue_to_address>
**Pruning tests provide no coverage**
When the project configures and runs its dock test suite, the dock test CMake configuration omits `desktopfileparserfactorytests.cpp`, so its tests never compile or run; moreover, `MockFactory` reimplements `createById()` and `pruneStaleEntries()` instead of testing `DesktopfileParserFactory<T>`, so adding the file to a target alone still leaves production pruning regressions undetected.
Add the test source to a dock test target and make the tests exercise `DesktopfileParserFactory<T>` rather than a copied `MockFactory` implementation.
Also at `tests/panels/dock/docktests/desktopfileparserfactorytests.cpp:14-16`, `tests/panels/dock/docktests/desktopfileparserfactorytests.cpp:39-47`, `tests/panels/dock/docktests/desktopfileparserfactorytests.cpp:72`.
</issue_to_address>
18202781743
reviewed
Nov 20, 2026
| Q_EMIT activeChanged(); | ||
| Q_EMIT attentionChanged(); | ||
| }); | ||
| }, Qt::UniqueConnection); |
mhduiy
force-pushed
the
agent/bugfix/383693
branch
from
November 20, 2026 17:06
36b1537 to
e5cd7ad
Compare
|
mhduiy
force-pushed
the
agent/bugfix/383693
branch
from
November 23, 2026 01:37
e5cd7ad to
1f2eda3
Compare
1. Root cause: ForeignToplevelHandle created via bare new without QObject parent in treeland_foreign_toplevel_manager_v3_toplevel(), only handlerIsReady connected but not handlerIsDeleted; when Wayland closed event arrives before done event, handle is never claimed or deleted, becoming orphaned and leaking memory 2. Fix: connect handlerIsDeleted signal at handle creation time, and add else branch in handleForeignToplevelHandleRemoved() to call deleteLater() for handles not yet in m_windows 3. Impact: only affects handle lifecycle for closed-before-done case; normal flow unchanged, no API change fix: 修复treeland toplevel句柄内存泄漏 1. 根因:treeland_foreign_toplevel_manager_v3_toplevel()中裸new创建 ForeignToplevelHandle仅连接handlerIsReady未连接handlerIsDeleted, closed事件先于done到达时handle无法认领或清理成为孤儿对象导致泄漏 2. 方案:handle创建时即连接handlerIsDeleted信号,并在 handleForeignToplevelHandleRemoved()新增else分支对不在m_windows的 pending handle调用deleteLater() 3. 影响:仅影响closed-before-done场景handle生命周期;正常流程不受 影响,无接口变更 PMS: BUG-383693
mhduiy
force-pushed
the
agent/bugfix/383693
branch
from
November 30, 2026 05:19
1f2eda3 to
2e8e4a8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root Cause Analysis
In
panels/dock/taskmanager/treelandwindowmonitor.cpp,ForeignToplevelManager::treeland_foreign_toplevel_manager_v3_toplevel()createsForeignToplevelHandlevia barenewwithout a QObject parent. It only connects thehandlerIsReadysignal (triggered by the Waylanddoneevent) but does not connecthandlerIsDeleted(triggered by theclosedevent). When a Wayland toplevel'sclosedevent arrives before itsdoneevent — which happens with short-lived windows, popup menus, and tooltips — thehandlerIsDeletedsignal is emitted but has no listener,handlerIsReadynever fires, and the handle object is never claimed bym_windowsor deleted. It becomes a permanently orphaned object, leaking memory on every such occurrence.Fix
Connect
handlerIsDeletedat handle creation time (line 31), and add anelsebranch inhandleForeignToplevelHandleRemoved()to calldeleteLater()on handles that were closed before being added tom_windows(the closed-before-done case). Normal flow (done-before-closed) is unchanged:handlerIsDeletedis also connected insidehandleForeignToplevelHandleAdded()viaQt::UniqueConnection, so no duplicate connections occur.Change Safety Assessment
Code Safety
new+ onlyhandlerIsReadyconnected) has existed since the initial implementation (commit 5106900, 2023-11-07) and survived three protocol migrations (wayland → treeland → treeland-v3). This fix does not revert any historical fix.handleForeignToplevelHandleRemovedis a private slot with no external callers; the newelsebranch only affects the closed-before-done edge case.Business Impact Scope
Affects the dock task manager's Wayland toplevel handle lifecycle. Users performing routine dock operations (opening/closing apps, switching windows, using popup menus) will no longer experience unbounded memory growth in the
org.deepin.ds.dockprocess. No behavior change for normal window open/close flow.Verification Suggestion
Test dock memory stability across repeated app open/close cycles, especially rapid window creation and destruction (popups, tooltips). Monitor
org.deepin.ds.dockRSS over an extended session and confirm it plateaus rather than growing indefinitely.根因分析
在
panels/dock/taskmanager/treelandwindowmonitor.cpp中,ForeignToplevelManager::treeland_foreign_toplevel_manager_v3_toplevel()使用裸new创建ForeignToplevelHandle,无 QObject parent。该函数仅连接了handlerIsReady信号(由 Waylanddone事件触发),未连接handlerIsDeleted信号(由closed事件触发)。当 Wayland toplevel 的closed事件先于done事件到达时(短暂窗口、弹出菜单、tooltip 等场景),handlerIsDeleted信号被 emit 但无监听者,handlerIsReady永不触发,handle 对象既不被m_windows认领也不被清理,成为永久泄漏的孤儿对象。修复方案
在 handle 创建时即连接
handlerIsDeleted信号(第31行),并在handleForeignToplevelHandleRemoved()中新增else分支,对不在m_windows中的 pending handle 调用deleteLater()(closed-before-done 场景)。正常流程(done 先于 closed)不受影响:handleForeignToplevelHandleAdded()中也通过Qt::UniqueConnection连接了handlerIsDeleted,不会产生重复连接。改动安全评估
代码安全评估
new+ 仅连接handlerIsReady)自初始实现即存在(commit 5106900, 2023-11-07),经历三次协议迁移(wayland → treeland → treeland-v3)均保留了相同的泄漏模式。本次修复不撤销任何历史修复。handleForeignToplevelHandleRemoved是 private slot,无外部调用者;新增的else分支仅影响 closed-before-done 边界场景。业务影响范围
影响任务栏 Wayland toplevel handle 的生命周期管理。用户在任务栏进行常规操作(打开/关闭应用、切换窗口、使用弹出菜单等)时,
org.deepin.ds.dock进程内存不再持续增长。正常窗口打开/关闭流程无行为变化。验证建议
测试任务栏在反复开关应用场景下的内存稳定性,特别是快速创建和销毁窗口(弹出菜单、tooltip)。长时间监控
org.deepin.ds.dock进程 RSS,确认其趋于稳定而非持续增长。